//
//  resultVC.m
//  jiaKaoZhuShou
//
//  Created by 金艺社 on 2018/5/18.
//  Copyright © 2018年 金艺社. All rights reserved.
//
/*
  把所有 成功或者失败结果的功能 都在此处处理
 */
#import "resultVC.h"
#import "myBill.h"
#import "chongZhiTiXianRecordVC.h"
#import "returnMoneyRecord.h"
@interface resultVC ()
@property (weak, nonatomic) IBOutlet UIImageView *relult_img;
@property (weak, nonatomic) IBOutlet UILabel *relult_lab;
@property (weak, nonatomic) IBOutlet UILabel *fialPrompt_lab;
@property (weak, nonatomic) IBOutlet UIButton *return_btn;
@property (weak, nonatomic) IBOutlet UIButton *determine_btn;
@property (weak, nonatomic) IBOutlet UIButton *homePage_btn;
@property (weak, nonatomic) IBOutlet UIView *back_V;


@end

@implementation resultVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"报名结果";
    if (self.resultType.intValue % 2 == 1) {
        if ([self.resultType isEqualToString:@"1"] || [self.resultType isEqualToString:@"11"]) { //报名成功 / 全额付款成功
            if ([self.resultType isEqualToString:@"11"]) {
                self.relult_lab.textColor = [UIColor custom_color:@"#6AB46C"];
                self.relult_lab.text = @"支付成功！";
                self.relult_img.image = [UIImage imageNamed:@"success"];
            }else {
                self.relult_lab.textColor = [UIColor custom_color:@"#E69D24"];
                self.relult_lab.text = @"等待审核结果！";
                self.relult_img.image = [UIImage imageNamed:@"waitingAudit"];
            }
            self.fialPrompt_lab.hidden = YES;
            self.homePage_btn.layer.masksToBounds = YES;
            self.homePage_btn.layer.cornerRadius = 22;
            self.return_btn.hidden = YES;
            self.determine_btn.hidden = YES;
        }else if ([self.resultType isEqualToString:@"3"]){ //还款成功
            self.relult_lab.textColor = [UIColor custom_color:@"#6AB46C"];
            self.relult_lab.text = @"恭喜，还款成功！";
            self.fialPrompt_lab.hidden = YES;
            self.relult_img.image = [UIImage imageNamed:@"success"];
            self.homePage_btn.hidden = YES;
            self.return_btn.layer.masksToBounds = YES;
            self.return_btn.layer.borderColor = [UIColor custom_color:@"#A91E23"].CGColor;
            self.return_btn.layer.borderWidth = 1;
            self.return_btn.layer.cornerRadius = 22;
            [self.return_btn setTitle:@"还款记录" forState:0];
            self.determine_btn.layer.masksToBounds = YES;
            self.determine_btn.layer.cornerRadius = 22;
            [self.determine_btn setTitle:@"确认" forState:0];
        }else if ([self.resultType isEqualToString:@"5"]){//认证成功
            self.relult_lab.textColor = [UIColor custom_color:@"#6AB46C"];
            self.relult_lab.text = @"恭喜，认证成功！";
            self.fialPrompt_lab.text = @"您可进行分期付款";
            self.relult_img.image = [UIImage imageNamed:@"success"];
            self.homePage_btn.layer.masksToBounds = YES;
            self.homePage_btn.layer.cornerRadius = 22;
            [self.determine_btn setTitle:@"返回" forState:0];
            self.return_btn.hidden = YES;
            self.determine_btn.hidden = YES;
        }else if ([self.resultType isEqualToString:@"7"]){//充值成功
            self.relult_lab.textColor = [UIColor custom_color:@"#6AB46C"];
            self.relult_lab.text = @"恭喜，充值成功！";
            self.fialPrompt_lab.text = @"支付金额：";
            self.relult_img.image = [UIImage imageNamed:@"success"];
            self.homePage_btn.hidden = YES;
            self.return_btn.layer.masksToBounds = YES;
            self.return_btn.layer.borderColor = [UIColor custom_color:@"#A91E23"].CGColor;
            self.return_btn.layer.borderWidth = 1;
            self.return_btn.layer.cornerRadius = 22;
            [self.return_btn setTitle:@"查看明细" forState:0];
            self.determine_btn.layer.masksToBounds = YES;
            self.determine_btn.layer.cornerRadius = 22;
            [self.determine_btn setTitle:@"立即还款" forState:0];
        }else if ([self.resultType isEqualToString:@"9"]){//提现成功
            self.relult_lab.textColor = [UIColor custom_color:@"#6AB46C"];
            self.relult_lab.text = @"提现申请成功，等待处理";
            self.fialPrompt_lab.text = @"到账时间说明：工作日下午16:00之前申请的提现会在当日18:00左右到账，16:00之后申请的提现将在下个工作日到账。周末及法定假日提现，将在下个工作日到账。";
            self.fialPrompt_lab.textAlignment= NSTextAlignmentLeft;
            self.relult_img.image = [UIImage imageNamed:@"success"];
            self.homePage_btn.layer.masksToBounds = YES;
            self.homePage_btn.layer.cornerRadius = 22;
            [self.homePage_btn setTitle:@"确定" forState:0];
            self.return_btn.hidden = YES;
            self.determine_btn.hidden = YES;
            [self addbankView];
        }
    }else {
        if ([self.resultType isEqualToString:@"2"]) {//报名失败
            self.homePage_btn.hidden = YES;
            self.return_btn.layer.masksToBounds = YES;
            self.return_btn.layer.borderColor = [UIColor custom_color:@"#A91E23"].CGColor;
            self.return_btn.layer.borderWidth = 1;
            self.return_btn.layer.cornerRadius = 22;
            self.determine_btn.layer.masksToBounds = YES;
            self.determine_btn.layer.cornerRadius = 22;
        }else if ([self.resultType isEqualToString:@"4"]){//还款失败
           //无效果图示
        }else if ([self.resultType isEqualToString:@"6"]){//认证失败
            self.homePage_btn.layer.masksToBounds = YES;
            self.homePage_btn.layer.cornerRadius = 22;
            self.relult_lab.text = @"审核失败！";
            self.fialPrompt_lab.text = @"请仔细填写核对个人信息";
        }else if ([self.resultType isEqualToString:@"8"]){//充值失败
            self.homePage_btn.layer.masksToBounds = YES;
            self.homePage_btn.layer.cornerRadius = 22;
            self.relult_lab.text = @"充值失败！";
            self.fialPrompt_lab.text = @"银行系统异常";
        }else if ([self.resultType isEqualToString:@"10"]){
            
        }
    }
}
- (IBAction)return_click:(UIButton *)sender {
    if ([sender.titleLabel.text isEqualToString:@"查看明细"]) {
        chongZhiTiXianRecordVC *VC = [chongZhiTiXianRecordVC new];
        VC.title = @"充值记录";
        [self.navigationController pushViewController:VC animated:YES];
    }else if ([sender.titleLabel.text isEqualToString:@"还款记录"]) {
        returnMoneyRecord *VC = [returnMoneyRecord new];
        [self.navigationController pushViewController:VC animated:YES];
    }else {
        [self.navigationController popViewControllerAnimated:YES];
    }
}
- (IBAction)determine_click:(UIButton *)sender {
    if ([sender.titleLabel.text isEqualToString:@"立即还款"]) {//立即还款
        myBill *VC = [myBill new];
        [self.navigationController pushViewController:VC animated:YES];
    }else {
        [self.navigationController popViewControllerAnimated:YES];
    }
}
- (IBAction)homePage_click:(UIButton *)sender {
    if ([sender.titleLabel.text isEqualToString:@"返回首页"]) {
         [self.navigationController popToRootViewControllerAnimated:YES];
    }else {
        [self.navigationController popViewControllerAnimated:YES];
    }
}
//提现使用
- (void)addbankView {
    UIView *container = [UIView new];
    container.backgroundColor = [UIColor custom_color:@"#FFFFFF"];
    [self.view addSubview:container];
    [container mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.back_V.mas_bottom).offset(10);
        make.left.right.equalTo(self.view);
        make.height.equalTo(@40);
    }];
    for (int i = 1; i < 2; i++) {
        UILabel *titleLab = [UILabel new];
        if(i == 0) {
            titleLab.text = @"提现至";
        }else {
            titleLab.text = @"提现金额";
        }
        titleLab.font = [UIFont customFontOfSize:12];
        titleLab.textColor = [UIColor custom_color:@"#333333"];
        [container addSubview:titleLab];
        [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@20);
            if (i == 0) {
                make.top.equalTo(@15);
            }else {
                make.bottom.equalTo(container.mas_bottom).offset(-15);
            }
        }];
        UILabel *contentLab = [UILabel new];
        if (i == 0) {
            contentLab.text = @"工商银行(尾号4231)";
            contentLab.font = [UIFont customFontOfSize:15];
            contentLab.textColor = [UIColor custom_color:@"#333333"];
        }else {
            contentLab.text = [NSString stringWithFormat:@"%@", self.withdraw];
            contentLab.font = [UIFont customFontOfSize:12];
            contentLab.textColor = [UIColor custom_color:@"#A91E23"];
        }
        [container addSubview:contentLab];
        [contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@-15);
            make.centerY.equalTo(titleLab.mas_centerY);
        }];
        if (i == 0) {
            UIImageView *bankImg = [UIImageView new];
            bankImg.image = [UIImage imageNamed:@"mine_bankCard_ICBC_icon"];
            [container addSubview:bankImg];
            [bankImg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(contentLab.mas_left).offset(-5);
                make.centerY.equalTo(contentLab.mas_centerY);
            }];
        }
    }
    [self.homePage_btn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(container.mas_bottom).offset(20).priority(601);
        make.left.equalTo(@16);
        make.right.equalTo(@-16);
        make.height.equalTo(@44);
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
